home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume5 / pbm3 / part5 < prev    next >
Encoding:
Internet Message Format  |  1989-02-03  |  12.2 KB

  1. Path: xanth!nic.MR.NET!hal!ncoast!allbery
  2. From: jef@helios.ee.lbl.gov (Jef Poskanzer)
  3. Newsgroups: comp.sources.misc
  4. Subject: v05i045: portable bitmap routines (5 of 5)
  5. Message-ID: <8811010237.AA02702@helios.ee.lbl.gov>
  6. Date: 9 Nov 88 02:41:24 GMT
  7. Sender: allbery@ncoast.UUCP
  8. Reply-To: jef@helios.ee.lbl.gov (Jef Poskanzer)
  9. Lines: 354
  10. Approved: allbery@ncoast.UUCP
  11.  
  12. Posting-number: Volume 5, Issue 45
  13. Submitted-by: "Jef Poskanzer" <jef@helios.ee.lbl.gov>
  14. Archive-name: pbm3/Part5
  15.  
  16. #! /bin/sh
  17. # This is a shell archive, meaning:
  18. # 1. Remove everything above the #! /bin/sh line.
  19. # 2. Save the resulting text in a file.
  20. # 3. Execute the file with /bin/sh (not csh) to create the files:
  21. #    pbm.h
  22. #    libpbm.h
  23. #    macp.h
  24. #    x10wd.h
  25. #    x11wd.h
  26. #    pbm.5
  27. #    bmaliases
  28. #    bitreverse.h
  29. # This archive created: Mon Oct 31 18:33:41 1988
  30. # By:    Jef Poskanzer (Paratheo-Anametamystikhood Of Eris Esoteric, Ada Lovelace Cabal)
  31. export PATH; PATH=/bin:$PATH
  32. echo shar: extracting "'pbm.h'" '(480 characters)'
  33. if test -f 'pbm.h'
  34. then
  35.     echo shar: will not over-write existing file "'pbm.h'"
  36. else
  37. sed 's/^X//' << \SHAR_EOF > 'pbm.h'
  38. X/* pbm.h - header file for libpbm portable bitmap library
  39. X*/
  40. X
  41. Xtypedef unsigned char bit;
  42. X
  43. X/* Declarations of routines. */
  44. X
  45. Xbit **pbm_allocarray( );
  46. X    /* bits = pbm_allocarray( cols, rows ); bits[row][col]; */
  47. X
  48. Xbit **pbm_readpbm( );
  49. X    /* bits = pbm_readpbm( file, &cols, &rows ); */
  50. Xpbm_writepbm( );
  51. X    /* pbm_writepbm( file, bits, cols, rows ); */
  52. X
  53. Xbit **pbm_readcbm( );
  54. X    /* bits = pbm_readcbm( file, &cols, &rows ); */
  55. Xpbm_writecbm( );
  56. X    /* pbm_writecbm( file, bits, cols, rows ); */
  57. SHAR_EOF
  58. if test 480 -ne "`wc -c < 'pbm.h'`"
  59. then
  60.     echo shar: error transmitting "'pbm.h'" '(should have been 480 characters)'
  61. fi
  62. fi # end of overwriting check
  63. echo shar: extracting "'libpbm.h'" '(382 characters)'
  64. if test -f 'libpbm.h'
  65. then
  66.     echo shar: will not over-write existing file "'libpbm.h'"
  67. else
  68. sed 's/^X//' << \SHAR_EOF > 'libpbm.h'
  69. X/* libpbm.h - internal header file for libpbm portable bitmap library
  70. X*/
  71. X
  72. X#define PBM_MAGIC1 'P'
  73. X#define PBM_MAGIC2 '1'
  74. X
  75. X#define CBM_MAGIC1 42
  76. X#define OCBM_MAGIC2 23
  77. X#define NCBM_MAGIC2 24
  78. X
  79. X#define VERSION_OLDCBM 1
  80. X#define VERSION_RUNLEN 2
  81. X
  82. X#define DEFAULT_BITSPERCOUNT 8
  83. X#define MAX_BITSPERCOUNT 12
  84. X#define MAX_MAXCOUNT 8191
  85. X
  86. X#define DEFAULT_REPEATBITS 2
  87. X#define MAX_REPEATBITS 32
  88. SHAR_EOF
  89. if test 382 -ne "`wc -c < 'libpbm.h'`"
  90. then
  91.     echo shar: error transmitting "'libpbm.h'" '(should have been 382 characters)'
  92. fi
  93. fi # end of overwriting check
  94. echo shar: extracting "'macp.h'" '(161 characters)'
  95. if test -f 'macp.h'
  96. then
  97.     echo shar: will not over-write existing file "'macp.h'"
  98. else
  99. sed 's/^X//' << \SHAR_EOF > 'macp.h'
  100. X/* macp.h - header file for MacPaint files
  101. X*/
  102. X
  103. X#define    HEADER_LENGTH    512
  104. X#define    MAX_LINES    720
  105. X#define    BYTES_WIDE    72
  106. X#define MAX_COLS    576    /* = BYTES_WIDE * 8 */
  107. SHAR_EOF
  108. if test 161 -ne "`wc -c < 'macp.h'`"
  109. then
  110.     echo shar: error transmitting "'macp.h'" '(should have been 161 characters)'
  111. fi
  112. fi # end of overwriting check
  113. echo shar: extracting "'x10wd.h'" '(952 characters)'
  114. if test -f 'x10wd.h'
  115. then
  116.     echo shar: will not over-write existing file "'x10wd.h'"
  117. else
  118. sed 's/^X//' << \SHAR_EOF > 'x10wd.h'
  119. X/* x10wd.h - the following defs are taken from various X10 header files
  120. X*/
  121. X
  122. X#define XYFormat 0
  123. X#define ZFormat 1
  124. X
  125. X#define X10WD_FILE_VERSION 6
  126. Xtypedef struct {
  127. X    int header_size;        /* Size of the entire file header (bytes). */
  128. X    int file_version;        /* X10WD_FILE_VERSION */
  129. X    int display_type;        /* Display type. */
  130. X    int display_planes;        /* Number of display planes. */
  131. X    int pixmap_format;        /* Pixmap format. */
  132. X    int pixmap_width;        /* Pixmap width. */
  133. X    int pixmap_height;        /* Pixmap height. */
  134. X    short window_width;        /* Window width. */
  135. X    short window_height;    /* Window height. */
  136. X    short window_x;        /* Window upper left X coordinate. */
  137. X    short window_y;        /* Window upper left Y coordinate. */
  138. X    short window_bdrwidth;    /* Window border width. */
  139. X    short window_ncolors;    /* number of Color entries in this window */
  140. X    } X10WDFileHeader;
  141. X
  142. Xtypedef struct {
  143. X    int pixel;
  144. X    unsigned short red, green, blue;
  145. X    } X10Color;
  146. SHAR_EOF
  147. if test 952 -ne "`wc -c < 'x10wd.h'`"
  148. then
  149.     echo shar: error transmitting "'x10wd.h'" '(should have been 952 characters)'
  150. fi
  151. fi # end of overwriting check
  152. echo shar: extracting "'x11wd.h'" '(1692 characters)'
  153. if test -f 'x11wd.h'
  154. then
  155.     echo shar: will not over-write existing file "'x11wd.h'"
  156. else
  157. sed 's/^X//' << \SHAR_EOF > 'x11wd.h'
  158. X/* x11wd.h - the following defs are taken from various X.V11R2 header files
  159. X*/
  160. X
  161. X#define LSBFirst 0
  162. X#define MSBFirst 1
  163. X
  164. X#define XYBitmap 0
  165. X#define XYPixmap 1
  166. X#define ZPixmap 2
  167. X
  168. Xtypedef unsigned long xwdval;
  169. X#define X11WD_FILE_VERSION 7
  170. Xtypedef struct {
  171. X    xwdval header_size;        /* Size of the entire file header (bytes). */
  172. X    xwdval file_version;    /* X11WD_FILE_VERSION */
  173. X    xwdval pixmap_format;    /* Pixmap format */
  174. X    xwdval pixmap_depth;    /* Pixmap depth */
  175. X    xwdval pixmap_width;    /* Pixmap width */
  176. X    xwdval pixmap_height;    /* Pixmap height */
  177. X    xwdval xoffset;        /* Bitmap x offset */
  178. X    xwdval byte_order;        /* MSBFirst, LSBFirst */
  179. X    xwdval bitmap_unit;        /* Bitmap unit */
  180. X    xwdval bitmap_bit_order;    /* MSBFirst, LSBFirst */
  181. X    xwdval bitmap_pad;        /* Bitmap scanline pad */
  182. X    xwdval bits_per_pixel;    /* Bits per pixel */
  183. X    xwdval bytes_per_line;    /* Bytes per scanline */
  184. X    xwdval visual_class;    /* Class of colormap */
  185. X    xwdval red_mask;        /* Z red mask */
  186. X    xwdval green_mask;        /* Z green mask */
  187. X    xwdval blue_mask;        /* Z blue mask */
  188. X    xwdval bits_per_rgb;    /* Log base 2 of distinct color values */
  189. X    xwdval colormap_entries;    /* Number of entries in colormap */
  190. X    xwdval ncolors;        /* Number of Color structures */
  191. X    xwdval window_width;    /* Window width */
  192. X    xwdval window_height;    /* Window height */
  193. X    long window_x;        /* Window upper left X coordinate */
  194. X    long window_y;        /* Window upper left Y coordinate */
  195. X    xwdval window_bdrwidth;    /* Window border width */
  196. X    } X11WDFileHeader;
  197. X
  198. Xtypedef struct {
  199. X    unsigned long pixel;
  200. X    unsigned short red, green, blue;
  201. X    char flags;            /* do_red, do_green, do_blue */
  202. X    char pad;
  203. X    } X11XColor;
  204. SHAR_EOF
  205. if test 1692 -ne "`wc -c < 'x11wd.h'`"
  206. then
  207.     echo shar: error transmitting "'x11wd.h'" '(should have been 1692 characters)'
  208. fi
  209. fi # end of overwriting check
  210. echo shar: extracting "'pbm.5'" '(2500 characters)'
  211. if test -f 'pbm.5'
  212. then
  213.     echo shar: will not over-write existing file "'pbm.5'"
  214. else
  215. sed 's/^X//' << \SHAR_EOF > 'pbm.5'
  216. X.TH pbm 5 "31 August 1988"
  217. X.SH NAME
  218. Xpbm - portable bitmap file format
  219. X.SH DESCRIPTION
  220. XThe portable bitmap format is a lowest common denominator.
  221. XIt was originally designed to make it reasonable to mail bitmaps
  222. Xbetween different types of machines using the typical stupid network
  223. Xmailers we have today.
  224. XNow it serves as the common language of a large family of bitmap
  225. Xconversion filters.
  226. XThe definition is as follows:
  227. X.IP - 2
  228. XA "magic number" for identifying the file type.
  229. XA pbm file's magic number is the two characters "P1".
  230. X.IP - 2
  231. XWhitespace (blanks, TABs, CRs, LFs).
  232. X.IP - 2
  233. XA width, formatted as ASCII characters in decimal.
  234. X.IP - 2
  235. XWhitespace.
  236. X.IP - 2
  237. XA height, again in ASCII decimal.
  238. X.IP - 2
  239. XWhitespace.
  240. X.IP - 2
  241. XWidth * height bits, each either '1' or '0', starting at the top-left
  242. Xcorner of the bitmap, proceding in normal English reading order.
  243. X.IP - 2
  244. XThe character '1' means black, '0' means white.
  245. X.IP - 2
  246. XWhitespace in the bits section is ignored.
  247. X.IP - 2
  248. XCharacters from a "#" to the next end-of-line are ignored (comments).
  249. X.IP - 2
  250. XNo line may be longer than 70 characters.
  251. X.PP
  252. XHere is an example of a small bitmap in this format:
  253. X.PP
  254. X.nf
  255. XP1
  256. X# feep.pbm
  257. X24 7
  258. X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  259. X0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 1 1 1 0
  260. X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 1 0
  261. X0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 0 0 0 1 1 1 1 0
  262. X0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0
  263. X0 1 0 0 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 1 0 0 0 0
  264. X0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
  265. X.fi
  266. X.PP
  267. XPrograms that read this format should be as lenient as possible,
  268. Xaccepting anything that looks remotely like a bitmap.
  269. X.SH "SEE ALSO"
  270. Xbrushtopbm(1), cbmtopbm(1), giftopbm(1), icontopbm(1), macptopbm(1),
  271. Xpbmcatlr(1), pbmcattb(1), pbmcrop(1), pbmcut(1), pbmenlarge(1),
  272. Xpbmfliplr(1), pbmfliptb(1), pbminvert(1), pbmmake(1), pbmpaste(1),
  273. Xpbmtoascii(1), pbmtocbm(1), pbmtoicon(1), pbmtolj(1), pbmtomacp(1),
  274. Xpbmtops(1), pbmtoptx(1), pbmtorast(1), pbmtox10bm(1), pbmtox10wd(1),
  275. Xpbmtoxbm(1), pbmtoxwd(1), pbmtrnspos(1), rasttopbm(1),
  276. Xxbmtopbm(1), xwdtopbm(1), xxxtopbm(1)
  277. X.SH AUTHOR
  278. XCopyright (C) 1988 by Jef Poskanzer.
  279. X
  280. XPermission to use, copy, modify, and distribute this software and its
  281. Xdocumentation for any purpose and without fee is hereby granted, provided
  282. Xthat the above copyright notice appear in all copies and that both that
  283. Xcopyright notice and this permission notice appear in supporting
  284. Xdocumentation.  This software is provided "as is" without express or
  285. Ximplied warranty.
  286. SHAR_EOF
  287. if test 2500 -ne "`wc -c < 'pbm.5'`"
  288. then
  289.     echo shar: error transmitting "'pbm.5'" '(should have been 2500 characters)'
  290. fi
  291. fi # end of overwriting check
  292. echo shar: extracting "'bmaliases'" '(386 characters)'
  293. if test -f 'bmaliases'
  294. then
  295.     echo shar: will not over-write existing file "'bmaliases'"
  296. else
  297. sed 's/^X//' << \SHAR_EOF > 'bmaliases'
  298. X# This script must be sourced - it will not work if you run it in a sub-shell.
  299. X
  300. Xset _to_only="ascii lj ps ptx x10bm x10wd"
  301. Xset _from_only="brush gif xxx"
  302. Xset _both="cbm icon macp rast xbm xwd"
  303. X
  304. Xforeach i ( $_both $_from_only )
  305. X    foreach j ( $_both $_to_only )
  306. X    if ( $i != $j ) then
  307. X        alias ${i}to${j} "( ${i}topbm | pbmto${j} )"
  308. X    endif
  309. X    end
  310. Xend
  311. X
  312. Xunset _to_only _from_only _both
  313. SHAR_EOF
  314. if test 386 -ne "`wc -c < 'bmaliases'`"
  315. then
  316.     echo shar: error transmitting "'bmaliases'" '(should have been 386 characters)'
  317. fi
  318. fi # end of overwriting check
  319. echo shar: extracting "'bitreverse.h'" '(1992 characters)'
  320. if test -f 'bitreverse.h'
  321. then
  322.     echo shar: will not over-write existing file "'bitreverse.h'"
  323. else
  324. sed 's/^X//' << \SHAR_EOF > 'bitreverse.h'
  325. X/*
  326. X** bitreverse.h
  327. X**
  328. X** This particular array seems to be useful in a lot of bitmap
  329. X** conversion programs.  It's not used in pbm because bits are
  330. X** stored one per byte, for easier manipulation.  But if you wanted
  331. X** to write, for example, a program to directly convert Sun raster
  332. X** format into X bitmaps, you could use this.
  333. X*/
  334. X
  335. Xunsigned char bitreverse[256] = {
  336. X    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0,
  337. X    0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
  338. X    0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4,
  339. X    0x24, 0xa4, 0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
  340. X    0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c, 0x9c, 0x5c, 0xdc,
  341. X    0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
  342. X    0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca,
  343. X    0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
  344. X    0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6,
  345. X    0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
  346. X    0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1,
  347. X    0x21, 0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
  348. X    0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9, 0x19, 0x99, 0x59, 0xd9,
  349. X    0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
  350. X    0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd,
  351. X    0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
  352. X    0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3,
  353. X    0x33, 0xb3, 0x73, 0xf3, 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
  354. X    0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7,
  355. X    0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
  356. X    0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef, 0x1f, 0x9f, 0x5f, 0xdf,
  357. X    0x3f, 0xbf, 0x7f, 0xff};
  358. SHAR_EOF
  359. if test 1992 -ne "`wc -c < 'bitreverse.h'`"
  360. then
  361.     echo shar: error transmitting "'bitreverse.h'" '(should have been 1992 characters)'
  362. fi
  363. fi # end of overwriting check
  364. #    End of shell archive
  365. exit 0
  366.